package com.nine.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.nine.dao.TestResultFpaDao;
import com.nine.entity.PageSort;
import com.nine.entity.TestResultFpa;
import com.nine.service.TestResultFpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author ：Mr.宋（mrssx@qq.com）
 * @date ：Created in 2022/6/29 19:55
 * @description：测试结果service层实现类
 * @modified By：
 * @version: 1.0
 */
@Service
@EnableScheduling
public class TestResultFpaServiceImpl implements TestResultFpaService {
    @Autowired
    private TestResultFpaDao testResultFpaDao;
    //查询
    @Override
    public List<TestResultFpa> select(PageSort pageSort) {
        //开启分页
        PageHelper.startPage(pageSort.getPage(),pageSort.getLimit());
        List<TestResultFpa> testResultFpaList = testResultFpaDao.select(pageSort);
        Page page= (Page) testResultFpaList;
        return page;
    }

    //新增
    @Override
    public int add(TestResultFpa testResultFpa) {
        TestResultFpa testResultFpa1;
        // 日期格式转换
        //testResultFpa1.setCreateTime(Timestamp.valueOf(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())));
        return testResultFpaDao.add(testResultFpa);
    }

    //删除
    @Override
    public int delete(String[] resultId) {
        return testResultFpaDao.delete(resultId);
    }

    //修改
    @Override
    public int update(TestResultFpa testResultFpa) {
        return testResultFpaDao.update(testResultFpa);
    }

    //查询总条数
    @Override
    public int selectCount(PageSort pageSort) {
        return testResultFpaDao.selectCount(pageSort);
    }
}